﻿namespace IBTrader.Charts
{
    using System.Collections.Generic;
    using System.Linq;

    class BaseGraphics
    {
        internal const double Factor = 1;
        protected void Draw(IGraphics graphics, IEnumerable<IChart> charts, double width, double height)
        {
            //if (!changed && !Worker.Filters.OfType<IChart>().Any(c => c.Changed)) return false;

            var regions = charts.GroupBy(s => s.Region).OrderBy(i => i.Key).ToArray();
            for (int i = 0; i < regions.Length; i++)
            {
                var groups = regions[i].GroupBy(s => s.Group);
                foreach (var group in regions[i].GroupBy(s => s.Group))
                {
                    var region = new Region(regions, group, i, width, height);
                    foreach (IChart source in group)
                    {
                        source.Draw(graphics, region);
            //            source.Changed = false;
                    }
                }
            }
            //return true;
        }
    }
}